package com.cma.typhoon.web.controller;

import com.cma.dao.HistclandingRepository;
import com.cma.model.db.*;
import com.cma.model.param.TfDictionaryParam;
import com.cma.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 台风相关字典表
 * @Author hbb
 * @Date 2017/1/4 9:48
 */
@Controller
@RequestMapping("/dic")
public class TfDictionaryController {

    @Autowired
    private ChntpcloneclassinfoService chntpcloneclassinfoService;
    @Autowired
    private HistorydeclinationService historydeclinationService;
    @Autowired
    private TfcitydictionaryService tfcitydictionaryService;
    @Autowired
    private TfcountydictionaryService tfcountydictionaryService;
    @Autowired
    private TfprovindictionaryService tfprovindictionaryService;
    /**
     * 台风等级字典信息表
     * @return
     */
    @RequestMapping("/tfClassInfo")
    @ResponseBody
    public Object tfClassInfoAll(){
        List<Chntpcloneclassinfo> chn= chntpcloneclassinfoService.findAll();
        return chn;
    }

    /**
     * 台风等级根据英文名称获取相应数据
     * @param tfDictionaryParam
     * @return
     */
    @RequestMapping("/tfClassByEnName")
    @ResponseBody
    public Object tfClassByEnName(TfDictionaryParam tfDictionaryParam){
        tfDictionaryParam.setTfClassEnnname("bigClass");
        Chntpcloneclassinfo chn=chntpcloneclassinfoService.findByEnName(tfDictionaryParam);
        return  chn;
    }

    /**
     * 历史警戒线
     * @return
     */
    @RequestMapping("/tfHisDeclinenation")
    @ResponseBody
    public Object tfDeclinenation(){
       List<Historydeclination> list= historydeclinationService.FindAll();
        return list;
    }

    /**
     * 获取全部省份信息
     * @return
     */
    @RequestMapping("/getProviAll")
    @ResponseBody
    public Object getprovinAll(){
        List<Tfprovindictionary> list=tfprovindictionaryService.FindAll();
        return list;
    }
    /**
     * 根据省份编号获取相应的城市
     * @return
     */
    @RequestMapping("/getCitysBySf")
    @ResponseBody
    public Object getCitysBySf(TfDictionaryParam tfDictionaryParam){
        tfDictionaryParam.setPid("11");
        List<Tfcitydictionary> list=tfcitydictionaryService.findByPid(tfDictionaryParam);
        return list;
    }

    /**
     * 根据城市id获取县区相关数据
     * @param tfDictionaryParam
     * @return
     */
    @RequestMapping("/getCountByCt")
    @ResponseBody
    public Object getCountryByCity(TfDictionaryParam tfDictionaryParam ){
        tfDictionaryParam.setCtid("1101");
        List<Tfcountydictionary> list=tfcountydictionaryService.findCtid(tfDictionaryParam);
        return list;
    }
}
